﻿namespace ESheep
{
    using System;
    using System.Drawing;
    using System.Threading.Tasks;

    /// <summary>
    /// The debug tools.
    /// </summary>
    internal static class DebugTools
    {
        /// <summary>
        /// The drow line.
        /// </summary>
        /// <param name="xFrom">
        /// The x from.
        /// </param>
        /// <param name="yFrom">
        /// The y from.
        /// </param>
        /// <param name="xTo">
        /// The x to.
        /// </param>
        /// <param name="yTo">
        /// The y to.
        /// </param>
        public static void DrowLine(int xFrom, int yFrom, int xTo, int yTo)
        {
            Task.Factory.StartNew(
                () =>
                {
                    IntPtr dc = WinApi.WinApiGetDC(IntPtr.Zero);
                    Graphics gfx = Graphics.FromHdc(dc);
                    gfx.DrawLine(new Pen(Color.Red), xFrom, yFrom, xTo, yTo);
                    WinApi.WinApiReleaseDC(dc);
                });
        }

        public static void DrawRectangle(int x, int y, int width, int height)
        {
            Task.Factory.StartNew(
                () =>
                {
                    IntPtr dc = WinApi.WinApiGetDC(IntPtr.Zero);
                    Graphics gfx = Graphics.FromHdc(dc);
                    gfx.DrawRectangle(new Pen(Color.Red), x, y, width, height);
                    WinApi.WinApiReleaseDC(dc);
                });
        }

        /// <summary>
        /// The drow text.
        /// </summary>
        /// <param name="x">
        /// The x.
        /// </param>
        /// <param name="y">
        /// The y.
        /// </param>
        /// <param name="text">
        /// The text.
        /// </param>
        public static void DrowText(int x, int y, string text)
        {
            Task.Factory.StartNew(
                () =>
                {
                    IntPtr dc = WinApi.WinApiGetDC(IntPtr.Zero);
                    Graphics gfx = Graphics.FromHdc(dc);
                    gfx.DrawString(text, new Font("Tahoma", 12), Brushes.Red, new PointF(x, y));
                    WinApi.WinApiReleaseDC(dc);
                });
        }
    }
}
